<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Eventos extends CI_Controller {

	function __construct(){
		parent::__construct();
		$this->load->model('eventoM');
		
	}
	
	public function index()
	{	
		$this->load->model('eventoM');
		$data2['eventos']= $this->eventoM->listarAll();
		if($this->session->userdata('logueado')){
			$data = array();
			$data['nombre'] = $this->session->userdata('nombre');
			$this->load->view('header', $data);
		}else{
			redirect('usuarios/iniciar_sesion');
		}
		$this->load->view('eventos', $data2);
		$this->load->view('footer');

	}

	public	function agregar(){
		$this->load->library('form_validation');
		$this->load->model('eventoM');
		$evento = array(
					'nombre' => $this->input->post('nombre'),
					'descripcion' => $this->input->post('descripcion'),
					'fecha' => $this->input->post('fecha'),
					'cant_participantes' => $this->input->post('part'),
					'hora' => $this->input->post('hora'),
				);
		/*print_r($evento);exit();*/
		$id_generado = $this->eventoM->alta($evento);
	}

	public function listar(){
		


	}
}
